import asyncio

shared_num: int = 0
async_lock = asyncio.Lock()


async def async_task(name):
    global shared_num
    while True:
        async with async_lock:
            shared_num += 1
            print(f"{name} shared_num: {shared_num}")

        await asyncio.sleep(1)


async def main():
    await asyncio.gather(
        async_task("taskA"),
        async_task("taskB"),
    )


if __name__ == "__main__":
    asyncio.run(main())
